﻿using SlamDunk.CMS.Model.Base;
using SlamDunk.CMS.Model.ViewModel;

namespace SlamDunk.CMS.Model.DataModel
{
    /// <summary>
    /// 链接
    /// </summary>
    public class Link : BaseEntity
    {
        #region # 属性

        #region 链接类别Id —— int CategoryId
        /// <summary>
        /// 链接类别Id
        /// </summary>
        public int CategoryId { get; set; }
        #endregion

        #region 链接名称 —— string LinkName
        /// <summary>
        /// 链接名称
        /// </summary>
        public string LinkName { get; set; }
        #endregion

        #region 链接地址 —— string Url
        /// <summary>
        /// 链接地址
        /// </summary>
        public string Url { get; set; }
        #endregion

        #region 描述 —— string Description
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
        #endregion

        #region 排序 —— int Sort
        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }
        #endregion

        #region 图片路径 —— string ImagePath
        /// <summary>
        /// 图片路径
        /// </summary>
        public string ImagePath { get; set; }
        #endregion

        #region 导航属性 - 链接类别 —— LinkCategory LinkCategory
        /// <summary>
        /// 导航属性 - 链接类别
        /// </summary>
        public virtual LinkCategory LinkCategory { get; set; }
        #endregion

        #endregion

        #region # 方法

        #region 转换为视图模型 —— LinkView ToViewModel()
        /// <summary>
        /// 转换为视图模型
        /// </summary>
        /// <returns>视图模型</returns>
        public LinkView ToViewModel()
        {
            return new LinkView()
            {
                Id = this.Id,
                CategoryId = this.CategoryId,
                CategoryName = this.LinkCategory.CategoryName,
                LinkName = this.LinkName,
                Url = this.Url,
                Description = this.Description,
                Sort = this.Sort,
                ImagePath = this.ImagePath,
                AddTime = this.AddTime.ToString("yyyy-MM-dd HH:mm:ss"),
            };
        }
        #endregion

        #endregion
    }
}
